#!/usr/bin/env node

const Dog = require('./02-dog')

const d1 = new Dog('taidi', 5),
      d2 = new Dog('zangao', 9)
    
function onBark() {
    console.log(this.name, this.energy)
}

//on方法注册事件监听器
d1.on('bark', onBark.bind(d1))
d2.on('bark', onBark.bind(d2))

setTimeout(() => {
    d1.energy = 3
}, 6000)

